#include <bits/stdc++.h>

using namespace std;
struct SparseV
{
    int index,value;
    SparseV(int _idx,int _val)
    {
        this->index=_idx;
        this->value=_val;
    }
    bool operator<(const SparseV&sv) const
    {
        return this->index<sv.index;
    }
};
int main_64()
{
    int n,a,b,idx,val;
    long long ans=0;
    scanf("%d%d%d",&n,&a,&b);
    set<SparseV> sparse_vector;
    for (int i=0;i<a ;++i )
    {
        scanf("%d%d",&idx,&val);
        sparse_vector.insert(SparseV(idx,val));
    }
    for (int i=0;i<b ;++i )
    {
        scanf("%d%d",&idx,&val);
        auto it=sparse_vector.find(SparseV(idx,val));
        if (it!=sparse_vector.end())
        {
            ans+=it->value*val;
        }
    }
    printf("%lld",ans);
    return 0;
}
